<?php

use Faker\Factory as Faker;
use App\Models\GoodsNumberLog;
use App\Repositories\GoodsNumberLogRepository;

trait MakeGoodsNumberLogTrait
{
    /**
     * Create fake instance of GoodsNumberLog and save it in database
     *
     * @param array $goodsNumberLogFields
     * @return GoodsNumberLog
     */
    public function makeGoodsNumberLog($goodsNumberLogFields = [])
    {
        /** @var GoodsNumberLogRepository $goodsNumberLogRepo */
        $goodsNumberLogRepo = App::make(GoodsNumberLogRepository::class);
        $theme = $this->fakeGoodsNumberLogData($goodsNumberLogFields);
        return $goodsNumberLogRepo->create($theme);
    }

    /**
     * Get fake instance of GoodsNumberLog
     *
     * @param array $goodsNumberLogFields
     * @return GoodsNumberLog
     */
    public function fakeGoodsNumberLog($goodsNumberLogFields = [])
    {
        return new GoodsNumberLog($this->fakeGoodsNumberLogData($goodsNumberLogFields));
    }

    /**
     * Get fake data of GoodsNumberLog
     *
     * @param array $postFields
     * @return array
     */
    public function fakeGoodsNumberLogData($goodsNumberLogFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'goods_id' => $fake->randomDigitNotNull,
            'attribute_id' => $fake->randomDigitNotNull,
            'number' => $fake->randomDigitNotNull,
            'user_id' => $fake->randomDigitNotNull,
            'calculate' => $fake->randomDigitNotNull,
            'created_at' => $fake->word,
            'updated_at' => $fake->word
        ], $goodsNumberLogFields);
    }
}
